I've been given a new task to study how scale dependent bias varias as a function of HOD params and
chain = chain[chain[:,0] >=-1.0]
chain = chain[chain[:, -1] <=0.5]
ordered_param_names = ['mean_occupation_satellites_assembias_param1','logMmin',
'mean_occupation_centrals_assembias_param1','logM1',
'logM0','sigma_logM', 'alpha', 'f_c']
# biases = []
indicies = np.random.choice(chain.shape[0], size = 1000, replace = False)
for i, row in enumerate(chain[indicies]):
print i
hod_params = dict(zip(ordered_param_names, row))
cat.populate(hod_params)
bias = cat.calc_bias(rbins, use_corrfunc = False)
biases.append(bias)
#plt.plot(rbc, bias, alpha = 0.1, color = 'b')
xis = []
indicies = np.random.choice(chain.shape[0], size = 100, replace = False)
for i, row in enumerate(chain[indicies]):
print i
hod_params = dict(zip(ordered_param_names, row))
hod_params['mean_occupation_centrals_assembias_param1'] = -1.0
hod_params['mean_occupation_satellites_assembias_param1'] = 0.0
cat.populate(hod_params)
xi = cat.calc_xi(rbins, use_corrfunc = False, do_jackknife=False)
print xi
xis.append(xi)
#plt.plot(rbc, bias, alpha = 0.1, color = 'b')
for xi in xis:
plt.plot(rbc, xi/xi_mm, alpha = 0.1, color = 'b')
plt.xscale('log')
plt.xlabel(r'$r$ [Mpc]')
plt.ylabel(r'$\xi_{gg}/\xi_{mm}(r)$')
plt.ylim([0.0, 2.0])
plt.xlim([1e0, 40])
plt.title(r"$\mathcal{A}_{cen}$ = %.1f, $\mathcal{A}_{sat}$ = %.1f"%(hod_params['mean_occupation_centrals_assembias_param1'],hod_params['mean_occupation_satellites_assembias_param1']))
plt.show()
xis = []
indicies = np.random.choice(chain.shape[0], size = 100, replace = False)
for i, row in enumerate(chain[indicies]):
ab_xis = []
print i
for a_cen, a_sat in [(0.0, 0.0), (1.0, 0.0), (-1.0, 0.0), (0.0, 1.0), (0.0, -1.0)]:
hod_params = dict(zip(ordered_param_names, row))
hod_params['mean_occupation_centrals_assembias_param1'] = a_cen
hod_params['mean_occupation_satellites_assembias_param1'] = a_sat
cat.populate(hod_params)
xi = cat.calc_xi(rbins, use_corrfunc = False, do_jackknife=False)
ab_xis.append(xi)
xis.append(ab_xis)
#plt.plot(rbc, bias, alpha = 0.1, color = 'b')
for j, xi in enumerate(xis):
for i, (ab_xi, c) in enumerate(zip(xi, ['b', 'r', 'g', 'm', 'k']) ):
if i > 3:
continue
if j == 0:
if i == 0:
plt.plot(rbc, ab_xi/xi_mm, color = c,label = 'No AB')
if i==1:
plt.plot(rbc, ab_xi/xi_mm, color = c,label = 'Positive AB')
if i == 2:
plt.plot(rbc, ab_xi/xi_mm, color = c,label = 'Negative AB')
else:
plt.plot(rbc, ab_xi/xi_mm, alpha = 0.05, color = c)
plt.xscale('log')
plt.xlabel(r'$r$ [Mpc]')
plt.ylabel(r'$\xi_{gg}/\xi_{mm}(r)$')
plt.ylim([0.0, 2.0])
plt.xlim([1e0, 40])
plt.legend(loc='best')
plt.title(r"Maximal AB Values")
plt.show()
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
---------------------------------------------------------------------------
KeyboardInterrupt Traceback (most recent call last)
<ipython-input-11-b5744e8e7df8> in <module>()
5 try:
6 hod_params = dict(zip(ordered_param_names, row))
----> 7 cat.populate(hod_params)
8 xi = cat.calc_xi(rbins, use_corrfunc = False, do_jackknife=False)
9 xis.append(xi)
/u/ki/swmclau2/.local/lib/python2.7/site-packages/pearce/mocks/cat.pyc in populate(self, params, min_ptcl)
707 # might be able to check is model has_attr mock.
708 if self.populated_once:
--> 709 self.model.mock.populate(Num_ptcl_requirement=min_ptcl)
710 else:
711 self.model.populate_mock(self.halocat, Num_ptcl_requirement=min_ptcl)
/u/ki/swmclau2/.conda/envs/hodemulator/lib/python2.7/site-packages/halotools-0.6.dev4681-py2.7-linux-x86_64.egg/halotools/empirical_models/factories/hod_mock_factory.pyc in populate(self, seed, **kwargs)
326 for halocatkey in self.additional_haloprops:
327 self.galaxy_table[halocatkey][gal_type_slice] = np.repeat(
--> 328 self.halo_table[halocatkey], self._occupation[gal_type], axis=0)
329
330 self.galaxy_table['x'] = self.galaxy_table['halo_x']
/u/ki/swmclau2/.conda/envs/hodemulator/lib/python2.7/site-packages/numpy/core/fromnumeric.pyc in repeat(a, repeats, axis)
396
397 """
--> 398 return _wrapfunc(a, 'repeat', repeats, axis=axis)
399
400
/u/ki/swmclau2/.conda/envs/hodemulator/lib/python2.7/site-packages/numpy/core/fromnumeric.pyc in _wrapfunc(obj, method, *args, **kwds)
55 def _wrapfunc(obj, method, *args, **kwds):
56 try:
---> 57 return getattr(obj, method)(*args, **kwds)
58
59 # An AttributeError occurs if the object does not have
KeyboardInterrupt:
/u/ki/swmclau2/.conda/envs/hodemulator/lib/python2.7/site-packages/halotools-0.6.dev4681-py2.7-linux-x86_64.egg/halotools/mock_observables/two_point_clustering/clustering_helpers.py:134: UserWarning:
`sample1` exceeds `max_sample_size`
downsampling `sample1`...
warn(msg)
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
<ipython-input-12-801fd1ee18a8> in <module>()
----> 1 xi_mm = cat.calc_xi_mm(rbins)
/u/ki/swmclau2/.local/lib/python2.7/site-packages/pearce/mocks/cat.pyc in calc_xi_mm(self, rbins, n_cores, use_corrfunc)
682 else:
683 xi_all = tpcf(pos / self.h, rbins, period=self.Lbox / self.h, num_threads=n_cores,
--> 684 estimator='Landy-Szalay')
685
686 #cache, so we don't ahve to repeat this calculation several times.
/u/ki/swmclau2/.conda/envs/hodemulator/lib/python2.7/site-packages/halotools-0.6.dev4681-py2.7-linux-x86_64.egg/halotools/mock_observables/two_point_clustering/tpcf.pyc in tpcf(sample1, rbins, sample2, randoms, period, do_auto, do_cross, estimator, num_threads, max_sample_size, approx_cell1_size, approx_cell2_size, approx_cellran_size, RR_precomputed, NR_precomputed, seed)
362 D1D1, D1D2, D2D2 = _pair_counts(sample1, sample2, rbins, period,
363 num_threads, do_auto, do_cross, _sample1_is_sample2,
--> 364 approx_cell1_size, approx_cell2_size)
365
366 # count random pairs
/u/ki/swmclau2/.conda/envs/hodemulator/lib/python2.7/site-packages/halotools-0.6.dev4681-py2.7-linux-x86_64.egg/halotools/mock_observables/two_point_clustering/tpcf.pyc in _pair_counts(sample1, sample2, rbins, period, num_threads, do_auto, do_cross, _sample1_is_sample2, approx_cell1_size, approx_cell2_size)
121 num_threads=num_threads,
122 approx_cell1_size=approx_cell1_size,
--> 123 approx_cell2_size=approx_cell1_size)
124 D1D1 = np.diff(D1D1)
125 else:
/u/ki/swmclau2/.conda/envs/hodemulator/lib/python2.7/site-packages/halotools-0.6.dev4681-py2.7-linux-x86_64.egg/halotools/mock_observables/pair_counters/npairs_3d.pyc in npairs_3d(sample1, sample2, rbins, period, verbose, num_threads, approx_cell1_size, approx_cell2_size)
144
145 if num_threads > 1:
--> 146 pool = multiprocessing.Pool(num_threads)
147 result = pool.map(engine, cell1_tuples)
148 counts = np.sum(np.array(result), axis=0)
/u/ki/swmclau2/.conda/envs/hodemulator/lib/python2.7/multiprocessing/__init__.pyc in Pool(processes, initializer, initargs, maxtasksperchild)
230 '''
231 from multiprocessing.pool import Pool
--> 232 return Pool(processes, initializer, initargs, maxtasksperchild)
233
234 def RawValue(typecode_or_type, *args):
/u/ki/swmclau2/.conda/envs/hodemulator/lib/python2.7/multiprocessing/pool.pyc in __init__(self, processes, initializer, initargs, maxtasksperchild)
157 self._processes = processes
158 self._pool = []
--> 159 self._repopulate_pool()
160
161 self._worker_handler = threading.Thread(
/u/ki/swmclau2/.conda/envs/hodemulator/lib/python2.7/multiprocessing/pool.pyc in _repopulate_pool(self)
221 w.name = w.name.replace('Process', 'PoolWorker')
222 w.daemon = True
--> 223 w.start()
224 debug('added worker')
225
/u/ki/swmclau2/.conda/envs/hodemulator/lib/python2.7/multiprocessing/process.pyc in start(self)
128 else:
129 from .forking import Popen
--> 130 self._popen = Popen(self)
131 _current_process._children.add(self)
132
/u/ki/swmclau2/.conda/envs/hodemulator/lib/python2.7/multiprocessing/forking.pyc in __init__(self, process_obj)
119 self.returncode = None
120
--> 121 self.pid = os.fork()
122 if self.pid == 0:
123 if 'random' in sys.modules:
OSError: [Errno 12] Cannot allocate memory
colors = sns.diverging_palette(80, 190,l= 80, n=N)
sns.palplot(colors)
fig = plt.figure(figsize=(10,8))
for label, value, c in zip(varied_param_vals, bias_vals, colors):
plt.plot(rbc, value, label = r'$\log{M_{min}}= %.1f$'%label, color = c)
plt.xscale('log')
plt.legend(loc = 'best')
plt.xlabel(r'$r$ [Mpc]')
plt.ylabel(r'$b(r)$')
plt.title(r'Bias as a function of Central Log M Min $\log{M_{min}}$')